import * as Mock from 'mockjs'
const Random = Mock.Random

let sizeArray = ['M码', 'L码', 'XL码', 'XXL码', 'XXXL码', 'XXXXL码']
let colorArray = ['赤色', '橙色', '黄色', '绿色', '青色', '蓝色', '紫色']
let tags = ['7天无理由', '百亿补贴', '退换无忧']
let productNames = [
    'Moncler男士羽绒服I2 093 1A00142 68950 999',
    'yao弹力按摩发梳韩国进口气垫气囊按摩梳子送闺蜜朋友长辈方形蓝灰色',
    '阿玛尼灰色纯棉女士针织时装夹克3Y5G845JZBZ',
    '阿玛尼紫色羊毛女士半裙VMN05TVM022',
    '祖玛珑 杏桃花与蜂蜜身体乳250ml 滋润身体【免税版】',
    '一原得物（YIYUANDEWU）传家壶官方复古保温壶户外便携保温瓶焖茶壶家用大容量热水瓶暖壶 传家壶mini 595ML',
    'Bally女士腰带B CHAIN 15 901',
    '欧泽斯 男士针织西服外套 ZL-05828-3 黑色',
    'Michael Kors女士手提包32F3G3GC9J NAT PALEGOLD'
]
let specSize: Spec[] = []
for (let i = 0; i < sizeArray.length; i++) {
    specSize.push({
        id: Random.increment(),
        name: sizeArray[i],
        type: 1,
        categoryId: 1
    })
}

let specColor: Spec[] = []
for (let i = 0; i < colorArray.length; i++) {
    specColor.push({
        id: Random.increment(),
        name: colorArray[i],
        type: 2,
        categoryId: 2
    })
}

let specCategorySize: SpecCategory = {
    id: 1,
    name: '尺码',
    specs: specSize
}

let colorCategorySize: SpecCategory = {
    id: 2,
    name: '颜色',
    specs: specColor
}

let productArray: Product[] = []
for (let i = 0; i < productNames.length; i++) {
    productArray.push({
        id: Random.increment(),
        title: productNames[i],
        subTitle: '',
        price: Random.integer(100, 300),
        imageUrl: 'https://z1.ax1x.com/2023/09/20/pP5DeKJ.md.png',
        tags: tags,
        specCategorys: [specCategorySize, colorCategorySize],
        quantity: Random.integer(1, 3)
    })
}

let serviceArray: Product[] = []
for (let i = 0; i < 10; i++) {
    serviceArray.push({
        id: Random.increment(),
        title: i + '天保障服务',
        subTitle: '',
        price: Random.integer(10, 60),
        imageUrl: 'https://z1.ax1x.com/2023/09/20/pP5DeKJ.md.png',
        tags: tags,
        specCategorys: [colorCategorySize, colorCategorySize],
        quantity: Random.integer(1, 3)
    })
}

let activityArray: (Activity | undefined)[] = []
for (let i = 0; i < 5; i++) {
    let type = Random.integer(1, 3)
    let amount = Random.integer(10, 60)
    let full = Random.integer(100, 300)
    let discount = Random.integer(6, 9) / 10
    let giveProduct = productArray[Random.integer(0, productArray.length - 1)]
    let name = ''
    if (type == 1) {
        name = `满${full}减${amount}元`
    } else if (type == 2) {
        name = `满${full}打${discount! * 10}折`
    } else if (type == 3) {
        name = `满${full}赠送商品【${giveProduct.title}】`
    }
    activityArray.push({
        id: Random.increment(),
        type,
        name,
        full,
        amount,
        discount,
        giveProduct
    })
}
activityArray.push(undefined)

let couponArray: Coupon[] = []
for (let i = 0; i < 5; i++) {
    let type = Random.integer(1, 2)
    let amount = Random.integer(10, 60)
    let full = Random.integer(100, 300)
    let discount = Random.integer(6, 9) / 10
    let name = ''
    if (type == 1) {
        name = `满${full}减${amount}元`
    } else if (type == 2) {
        name = `满${full}打${discount! * 10}折`
    }
    couponArray.push({
        id: Random.increment(),
        type,
        name,
        full,
        amount,
        discount
    })
}

let cartItemArray: CartProductItem[] = []
for (let i = 0; i < Random.integer(3, productArray.length); i++) {
    cartItemArray.push({
        activityInfo: activityArray[Random.integer(0, activityArray.length - 1)],
        coupons: [
            {
                coupon: couponArray[Random.integer(0, couponArray.length - 1)],
                receive: true
            }
        ],
        productInfo: productArray[i],
        services: serviceArray,
        count: Random.integer(1, 3),
        specs: [specSize[Random.integer(0, sizeArray.length - 1)], specColor[Random.integer(0, colorArray.length - 1)]],
        userService: serviceArray[Random.integer(0, serviceArray.length - 1)]
    })
}

let res = {
    code: 200,
    message: 'ok',
    data: {
        coupons: [
            {
                coupon: couponArray[Random.integer(0, couponArray.length - 1)],
                receive: true,
                use: true
            }
        ],
        items: cartItemArray
    }
}

console.log(JSON.stringify(res))
